package mysql

import "gorm.io/gorm"

type Good struct {
	gorm.Model
	Name    string  `gorm:"type:varchar(30);not null;comment:'商品名称'" json:"name"`
	Content string  `gorm:"type:varchar(225);not null;comment:'商品介绍'" json:"content"`
	Price   float64 `gorm:"type:decimal(10,2);not null;comment:'商品价格'" json:"price"`
	Num     int64   `gorm:"type:int;not null;comment:'商品数量'" json:"num"`
	Status  int64   `gorm:"type:int;not null;comment:'商品状态'" json:"status"`
}

func (g *Good) Create() error {
	return DB.Debug().Create(&g).Error
}

func (g *Good) List() (list []*Good, err error) {
	err = DB.Debug().Find(&list).Error
	return nil, err
}
